package com.qf.mybatis01.mapper;

import com.qf.mybatis01.entity.User;
import org.apache.ibatis.annotations.*;

public interface UserMapper {

    @Select("select * from t_users where id = #{id}")
    public User getUserById(Integer id);

    @Select("SELECT * FROM t_users WHERE id = #{id} AND password = #{pwd}")
    public User selectUserByIdAndPwd_annotation(@Param("id") Integer id, @Param("pwd") String password);

    @Delete("delete from t_users where id = #{id}")
    public Integer deleteUserByid(@Param("id") Integer id);

    @Update("UPDATE t_users SET name = #{name} , password = #{password},birthday = #{birthday} WHERE id = #{id}")
    public int updateUser(User user);

    @Options(useGeneratedKeys = true , keyProperty = "id") // 自增key，主键为id
    @Insert("INSERT INTO t_users VALUES(null,#{name},#{password},#{sex},#{birthday},#{registTime},#{auth})")
    public int insertUserGeneratedKeys(User user);

}
